home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / pascal / djsquash.com / DJSQUASH.DOC < prev    next >
Encoding:
Text File  |  1989-04-06  |  4.5 KB  |  105 lines

  1. DJSquash 1.0
  2.   Author: DHStraayer
  3.  
  4. Usage: C:\DJSquash<Enter>
  5.  
  6. DJSquash is a Terminate-and-stay-resident program which
  7. compresses printer data directed to PRN, with the assumption that
  8. PRN is an HP DeskJet, and the program or programs writing to the
  9. DeskJet sometimes send raster data without compressing it.  It
  10. has been tested with the DRI GEM (R) DeskJet driver.
  11.      Source code is provided so that users can write other useful
  12. filters.  This could, for example, "touch up" the data from an
  13. application program that has a driver almost but not quite
  14. appropriate for a particular printer.  You know the problem, you
  15. bought an XYZ printer that is supposed to emulate an Epson
  16. mumble-mumble, but when you configure your application for an
  17. Epson mumble-mumble, the application keeps putting out an
  18. <escape>whatnot command that your XYZ printer doesn't understand.
  19. You want to write a filter that checks for the <escape>whatnot
  20. pattern and substitute an <escape>works-ok work-around.  Well,
  21. this source code will let you do that.
  22.  
  23. How it works:
  24.  
  25. DJSquash installs itself on interrupt 17H, the printer interrupt.
  26. It examines data going to the printer (or print spooler, if one
  27. has been installed).  If the data is uncompressed raster data,
  28. DJSquash intercepts it and compresses it with "Compression Mode
  29. 2", which is a rather clever hybrid of run-length coding and
  30. straight raster data.  This compression mode has considerably
  31. better worst-case behavior than regular run-length coding.
  32. Regular run-length coding has a worst-case behavior of causing
  33. the data to expand 2X.  This happens when the data is very
  34. "noisy" and all of the runs are of length 1.  Mode 2 consists of
  35. two kinds of data  interspersed.  The data types are <run-
  36. length>,<value> pairs, and  <data-length>,{uncompressed data}
  37. sets.  A single bit in the introducer  byte indicates whether the
  38. piece of data is a run or straight data.  This leaves seven bits
  39. to give either the run length or the number of uncompressed data
  40. bytes.
  41.  
  42.  
  43. Files in archive:
  44.  
  45. DJSquash.com
  46.      The TSR executable
  47. DJSquash.doc
  48.      This documentation you are reading
  49. DJSquash.c
  50.      The part of the C source code that manages TSR
  51.      stuff.
  52. C_Part.c
  53.  
  54.  
  55.      The Compression algorithm in C code.
  56. C_Test.C:
  57.      This corresponds to DJSquash.C, but provides a
  58.      non-TSR testing environment so you can use Turbo C
  59.      debugger to debug other printer filters.
  60. C_Test.prj
  61.      Project file for non-TSR debugging
  62. Makefile.
  63.      Makefile to make DJSquash.COM
  64.  
  65.  
  66. How to modify it:
  67.  
  68. The source code is broken into two parts, the TSR management code
  69. and the filter itself.  The filter is in C_part.c.  C_part
  70. consists of three public names.  C_init() is called by the TSR
  71. part to initialize things.  It should establish starting values
  72. for globals, and may actually send some initialization code to
  73. the printer.  Pchar(c) is in the TSR management (or debugging
  74. driver), and it is used by the filter to actually send one
  75. character to the printer, or spooler.  Finally, c_filt(c) is the
  76. filter itself.  It is called for each unfiltered character that
  77. your application program wants to send to the printer.  Of
  78. course, it is hard to detect patterns of characters in a one-at-
  79. a-time situation.  Therefore, c_filt is a "state machine"  which
  80. keeps track of what is going on via a "state variable" called
  81. (interestingly enough) "state".  For further details, read the
  82. source code.
  83.  
  84. Known problems:
  85.  
  86. After running the non-TSR debugging, a C_Part.obj may be left
  87. behind which wasn't compiled in -mT and may not work with
  88. DJSquash.obj.  After running non-TSR debugging, be sure to delete
  89. c_part.obj.  Then make will cause MAKE to re-compile properly.
  90.  
  91. DJSquash doesn't handle downloading fonts to DeskJet.  Probably
  92. will be OK, but if raster data as a part of the font definitions
  93. going to the printer just  happens to contain bytes which are the
  94. DeskJet command we are parsing for (like <esc>*r[0|1|NULL]A) it
  95. could get confused.  What to do? Well, it could parse for the
  96. commands that download data for font defs, and carefully ignore
  97. the "guts" data.  It does this something very much like this when
  98. it parses and ignores raster data that may have already been
  99. compressed.  In point of fact, the odds of this bug triggering
  100. are VERY slim, since it takes 32 bits of match to trigger the
  101. minimum 4 byte hit, and the odds are therefor in the parts-per-
  102. billion.  And font definitions aren't run-of-the-mill random
  103. data, either.  But if you are either a compulsive worrier, or
  104. suspect problems, you've got the source code!
  105.